import React, { lazy, Suspense } from "react";
import { rotuerListRowState } from "../type";
import { useRoutes } from "react-router-dom";
import { Home, Health, Video } from "@nutui/icons-react";
import { AppOutline, AntOutline, VideoOutline } from "antd-mobile-icons";
import loginImg from "../assets/hdpi/loading.gif";
// const A = lazy(()=>import('../myDemo/myVirtualList/a'))
// layout
const Alayout = lazy(() => import("../pages/ALayout"));
// 首页
const AHome = lazy(() => import("../pages/Ahome"));
// 搜索
const Asearch = lazy(() => import("../pages/Asearch"));

// 知识宝典
const AknowledgeBook = lazy(() => import("../pages/Aknowledge/AknowledgeBook"));
// 病症详情
const AknowledgeDetail = lazy(
  () => import("../pages/Aknowledge/AknowledgeDetail")
);
// 药品详情
// const AknowledgedragDetail = lazy(() => import("../pages/AknowledgeDragDetail"));
// 问诊咨询
const Aconsultation = lazy(
  () => import("../pages/Aconsultation/Aconsultatios")
);
// 问诊详情
const AdoctorDetail = lazy(() => import("../pages/Aconsultation/DoctorDetail"));
// 医生聊天页面
const DoctorChat = lazy(() => import("../pages/Aconsultation/doctorChat"));
// 评论列表
const MoreComment = lazy(() => import("../pages/Aconsultation/moreComment"));
// 健康资讯
const AHealthInformationDetail = lazy(
  () => import("../pages/AHealthInformation/AHealthInformationDetail")
);

// 病友圈
const BpatientHome = lazy(
  //病友圈首页
  () => import("../pages/BpatientCircle/BpatientCircleHome")
);

const BpatientLook = lazy(
  // 病友圈查看
  () => import("../pages/BpatientCircle/PeopleCommentList")
);

const BpatientWrite = lazy(
  // 病友圈写
  () => import("../pages/BpatientCircle/BpatientCircleWrite")
);

const BpatientSearch = lazy(
  // 病友圈搜索
  () => import("../pages/BpatientCircle/BpatientCircleSearch")
);

const BpatientCircleDetail = lazy(
  // 病友圈详情
  () => import("../pages/BpatientCircle/BpatientCircleDetail")
);

// 视频
const CvideoPage = lazy(() => import("../pages/CvideoPage"));

// 我的
const User = lazy(() => import("../pages/User/UserHome"));
// 登录
const UserLogin = lazy(() => import("../pages/User/UserLogin"));
// 注册
const UserRegister = lazy(() => import("../pages/User/UserRegister"));
// 个人信息
const UserInfo = lazy(() => import("../pages/User/UserInfo"));
// 我的收藏
const UserFavorite = lazy(() => import("../pages/User/UserFavorite"));
// 我的关注
const UserFollow = lazy(() => import("../pages/User/UserFollow"));
// eslint-disable-next-line react-refresh/only-export-components
export const RouterList: rotuerListRowState[] = [
  {
    path: "/",
    name: "layout",
    element: <Alayout />,
    children: [
      // 首页
      {
        path: "/",
        name: "AHome",
        meta: {
          label: "首页",
          icon: <AppOutline />,
        },
        element: <AHome />,
      },
      // 搜索
      {
        path: "/search",
        name: "search",
        element: <Asearch />,
      },
      // 问诊
      {
        path: "/Aconsultation",
        name: "Aconsultation",
        element: <Aconsultation />,
      },
      // 问诊详情
      {
        path: "/AdoctorDetail/:id",
        name: "AdoctorDetail",
        element: <AdoctorDetail />,
      },
      // 医生聊天页面
      {
        path: "/doctorChat/:id",
        name: "DoctorChat",
        element: <DoctorChat />,
      },
      // 评论列表
      {
        path: "/moreComment/:id",
        name: "MoreComment",
        element: <MoreComment />,
      },
      // 咨询详情
      {
        path: "/imdetail/:id",
        name: "imdetail",
        element: <AHealthInformationDetail />,
      },
      // 知识宝典（药品和病症）
      {
        path: "/knowledgeBook/:type/",
        name: "knowledgeBook",
        element: <AknowledgeBook />,
      },
      // 知识宝典详情
      {
        path: "/AknowledgeDetail/:type/:id",
        name: "AknowledgeDetail",
        element: <AknowledgeDetail />,
      },
      // 病友圈
      {
        path: "/BpatientCircle",
        name: "BpatientCircle",
        meta: {
          label: "病友圈",
          icon: <AntOutline />,
        },
        children: [
          // 首页
          {
            path: "/BpatientCircle/BpatientCircleHome",
            name: "BpatientCircleHome",
            meta: {
              icon: <Health />,
            },
            element: <BpatientHome />,
          },
          // 查看
          {
            path: "/BpatientCircle/BpatientCircleLook",
            name: "BpatientCircleLook",
            meta: {
              icon: <Health />,
            },
            element: <BpatientLook />,
          },
          // 写
          {
            path: "/BpatientCircle/BpatientCircleWrite",
            name: "BpatientCircleWrite",
            meta: {
              icon: <Health />,
            },
            element: <BpatientWrite />,
          },
          // 搜索
          {
            path: "/BpatientCircle/BpatientCircleSearch",
            name: "BpatientCircleSearch",
            meta: {
              icon: <Health />,
            },
            element: <BpatientSearch />,
          },
          // 病友圈详情
          {
            path: "/BpatientCircle/BpatientCircleDetail",
            name: "BpatientCircleDetail",
            element: <BpatientCircleDetail />,
          },
          // 用户发帖列表
          {
            path: "/BpatientCircle/PeopleCommentList",
            name: "PeopleCommentList",
            element: <BpatientLook />,
          },
        ],
      },
      // 视频
      {
        path: "/CvideoPage",
        name: "CvideoPage",
        meta: {
          label: "视频",
          icon: <VideoOutline />,
        },
        element: <CvideoPage />,
      },
      // 我的
      {
        path: "/user",
        name: "user",
        meta: {
          label: "我的",
        },
        element: <User />,
      },
      // 登录
      {
        path: "/login",
        name: "login",
        element: <UserLogin />,
      },
      // 注册
      {
        path: "/register",
        name: "register",
        element: <UserRegister />,
      },
      // 个人信息
      {
        path: "/userInfo",
        name: "userInfo",
        element: <UserInfo />,
      },
      // 我的收藏
      {
        path: "/userFavorite",
        name: "userFavorite",
        element: <UserFavorite />,
      },
      // 我的关注
      {
        path: "/userFollow",
        name: "userFollow",
        element: <UserFollow />,
      },
      //
    ],
  },
];

export const Router = () => {
  const Routes = () => useRoutes(RouterList);
  return (
    <Suspense
      fallback={
        <div
          style={{
            height: "100vh",
            display: "flex",
            alignItems: "center",
            justifyContent: "center",
          }}
        >
          <img style={{ width: "50%" }} src={loginImg} alt="" />
        </div>
      }
    >
      <Routes />
    </Suspense>
  );
};
